Skip to content

btc: broadcaster-gate FILL — submitblock RPC FALLBACK + never-silent-drop - #162

Merged
frstrtr merged 1 commit into
masterfrom
btc/broadcaster-gate-fallback
Jun 18, 2026
Merged

btc: broadcaster-gate FILL — submitblock RPC FALLBACK + never-silent-drop#162
frstrtr merged 1 commit into
masterfrom
btc/broadcaster-gate-fallback

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Broadcaster gate (BTC) — FILL (a)+(b)

Closes the won-block broadcaster gate for BTC. Implements the confirmed FALLBACK design (P2P relay primary; submitblock RPC fires only on P2P-unavailable/relay-failed — NOT always-both / no double-broadcast), plus both hard tightenings.

Tightening 1 — fallback on FAILURE, not only m_p2p==null

  • coin/p2p_node.hpp: submit_block_raw / submit_block_full now return bool (false when no peer or relay failed).
  • coin/node.hpp: submit_block_p2p_raw returns bool; new submit_block_hex (RPC sink) + submit_block_with_fallback.
  • coin/block_broadcast.hpp (new): broadcast_block_with_fallback() seam — try P2P; fall back to RPC whenever P2P is null or relay did not succeed.

Tightening 2 — never silent-drop

  • stratum/work_source.{hpp,cpp}: SubmitBlockFn returns bool; the won-block path logs a loud ERROR when a found block reaches NEITHER sink (or no fn is wired). Was a LOG_WARNING at the old :818.
  • c2pool/main_btc.cpp: stratum_submit_fn returns the fallback outcome.

Verify test (path 3)

test/block_broadcast_test.cpp (standalone harness, same style as the H5 tx_data_memo_test): 13/13 PASS.

  • happy (P2P up): P2P fires, RPC does NOT (proves fallback, not always-both)
  • degraded / null-p2p: RPC fallback fires
  • both-down: reaches neither → won-block path screams

Build: c2pool-btc GREEN. BTC-only; no cross-coin files touched.

NOTE on the test: it drives the new fallback seam with fakes that stand 1:1 for message_block::make_raw (P2P sink) and the submitblock CallMethod (RPC sink), proving the decision matrix deterministically. Happy-path asserts RPC does NOT fire — under the confirmed FALLBACK design, asserting both fire would contradict the no-double-broadcast decision. Can wire a full network-level integration test (fake CoindProtocol peer + fake jsonrpc client) as a follow-up if the gate requires literal observation of those two primitives.
BODY

…drop won block

Closes the won-block broadcaster gate for BTC. Prior path was single-sink:
the stratum won-block lambda called submit_block_p2p_raw only, and node.hpp
had a bare `if (m_p2p)` with no else — a silent-drop hole on a found block.

FALLBACK semantics (P2P relay primary; submitblock RPC fires only when P2P
is unavailable or relay failed — NOT always-both / no double-broadcast):

- coin/block_broadcast.hpp (new): broadcast_block_with_fallback() seam —
  pure, testable decision: try P2P; on null/fail fall back to RPC; returns
  true iff at least one sink accepted.
- coin/node.hpp: submit_block_p2p_raw now returns bool; new submit_block_hex
  (RPC sink via NodeRPC::submit_block_hex) and submit_block_with_fallback.
- coin/p2p_node.hpp: submit_block_raw / submit_block_full return bool
  (false when no peer or relay failed) so failure — not just null — triggers
  the fallback.
- stratum/work_source.{hpp,cpp}: SubmitBlockFn returns bool; the won-block
  path logs a loud ERROR when a found block reaches NEITHER sink (or no fn is
  wired). A won block can never be lost quietly.
- c2pool/main_btc.cpp: stratum_submit_fn returns the fallback outcome.
- test/block_broadcast_test.cpp (new): standalone gate harness, 13/13 PASS —
  happy (P2P only, RPC does NOT fire), degraded/null-p2p (RPC fallback fires),
  both-down (reaches neither -> won-block path screams).

BTC-only; build c2pool-btc GREEN.
@frstrtr
frstrtr merged commit 02a9571 into master Jun 18, 2026
16 checks passed
@frstrtr
frstrtr deleted the btc/broadcaster-gate-fallback branch June 18, 2026 19:00
frstrtr added a commit that referenced this pull request Jun 19, 2026
…lock (#223)

Embedded NMC submit path now relays found aux-blocks through a settable
BlockRelayFn sink (host wires it to CoinBroadcaster::submit_block_raw,
decoded at the wiring site, mirroring the BTC on_block_relay seam).
submit_block() no longer claims success unconditionally: an unwired relay
or a 0-peer broadcast surfaces as failure (never-silent-drop, per BTC #162)
while the hex is still cached for get_block_hex(). +3 KATs (relay exact-hex,
no-relay fail, 0-peer fail); existing cache KAT updated to the new contract.
Rides nmc_template_builder_test — no CMake/build.yml change.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
frstrtr added a commit that referenced this pull request Jun 20, 2026
…nt success) (#253)

The embedded submitauxblock RPC leg has no daemon to RPC and is not a
same-process fallback like BTC submitblock-to-bitcoind, so it cannot
itself broadcast and must not claim success. Return false, mirroring
submit_block() never-silent-drop (#162); the P2P relay via submit_block()
is the one authoritative embedded route. Updates the fallback-leg KAT to
assert false (supersedes integrator note #3 per UID1610) while keeping the
distinct no-cache invariant.

Punch-list item (2) of the 2d broadcaster gate; item (1) host m_block_relay
wiring + #251 won-block un-gate stay queued behind the #247/#251 tap.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant